package org.germinus.telcoblocks.infraestructuras.diagram.edit.policies;

import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.commands.Command;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.emf.commands.core.commands.DuplicateEObjectsCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;
import org.germinus.telcoblocks.TelcoblocksPackage;
import org.germinus.telcoblocks.infraestructuras.diagram.edit.commands.Centralita_VOIPCreateCommand;
import org.germinus.telcoblocks.infraestructuras.diagram.edit.commands.MediaServerCreateCommand;
import org.germinus.telcoblocks.infraestructuras.diagram.edit.commands.Servidor_APP_SIPCreateCommand;
import org.germinus.telcoblocks.infraestructuras.diagram.edit.commands.Servidor_VOIPCreateCommand;
import org.germinus.telcoblocks.infraestructuras.diagram.edit.commands.SoftPhone_VOIPCreateCommand;
import org.germinus.telcoblocks.infraestructuras.diagram.edit.commands.Telefono_VOIPCreateCommand;
import org.germinus.telcoblocks.infraestructuras.diagram.providers.TelcoblocksElementTypes;

/**
 * @generated
 */
public class REDItemSemanticEditPolicy extends
		TelcoblocksBaseItemSemanticEditPolicy {

	/**
	 * @generated
	 */
	protected Command getCreateCommand(CreateElementRequest req) {
		if (TelcoblocksElementTypes.SoftPhone_VOIP_2007 == req.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(TelcoblocksPackage.eINSTANCE
						.getRED_Terminales());
			}
			return getGEFWrapper(new SoftPhone_VOIPCreateCommand(req));
		}
		if (TelcoblocksElementTypes.Servidor_VOIP_2008 == req.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(TelcoblocksPackage.eINSTANCE
						.getRED_Servidor_VOIP());
			}
			return getGEFWrapper(new Servidor_VOIPCreateCommand(req));
		}
		if (TelcoblocksElementTypes.MediaServer_2009 == req.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(TelcoblocksPackage.eINSTANCE
						.getRED_MediaServer());
			}
			return getGEFWrapper(new MediaServerCreateCommand(req));
		}
		if (TelcoblocksElementTypes.Servidor_APP_SIP_2010 == req
				.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(TelcoblocksPackage.eINSTANCE
						.getRED_Servidor_APP_SIP());
			}
			return getGEFWrapper(new Servidor_APP_SIPCreateCommand(req));
		}
		if (TelcoblocksElementTypes.Centralita_VOIP_2011 == req
				.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(TelcoblocksPackage.eINSTANCE
						.getRED_Centralita_VOIP());
			}
			return getGEFWrapper(new Centralita_VOIPCreateCommand(req));
		}
		if (TelcoblocksElementTypes.Telefono_VOIP_2012 == req.getElementType()) {
			if (req.getContainmentFeature() == null) {
				req.setContainmentFeature(TelcoblocksPackage.eINSTANCE
						.getRED_Terminales());
			}
			return getGEFWrapper(new Telefono_VOIPCreateCommand(req));
		}
		return super.getCreateCommand(req);
	}

	/**
	 * @generated
	 */
	protected Command getDuplicateCommand(DuplicateElementsRequest req) {
		TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
				.getEditingDomain();
		return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req));
	}

	/**
	 * @generated
	 */
	private static class DuplicateAnythingCommand extends
			DuplicateEObjectsCommand {

		/**
		 * @generated
		 */
		public DuplicateAnythingCommand(
				TransactionalEditingDomain editingDomain,
				DuplicateElementsRequest req) {
			super(editingDomain, req.getLabel(), req
					.getElementsToBeDuplicated(), req
					.getAllDuplicatedElementsMap());
		}

	}

}
